<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<ul class="nav nav-tabs">
	<li <?php  if($do == 'post') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('gongdengfenxiang',array('act' => 'post'))?>">添加分享</a></li>
	<li <?php  if($do == 'display') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('gongdengfenxiang')?>">分享列表</a></li>
</ul>
<style>
#nav-tabs>li.active>a, #nav-tabs>li.active>a:hover, #nav-tabs>li.active>a:focus{ color:#333333; text-decoration:underline; }
</style>
<ul class="nav nav-tabs" id="nav-tabs" style="border:none;">
<?php  if(is_array($glist)) { foreach($glist as $glist) { ?>
	<li class="active">
    <a style="border:none; background:none;" href="<?php  echo $this->createWebUrl('gongdengfenxiang',array('display' => 1,'cid' =>$glist['class_id']))?>"><?php  echo $glist['classname'];?></a>
    </li>
<?php  } } ?>

</ul>
<style>
.table td span{display:inline-block;margin-top:4px;}
.table td input{margin-bottom:0;}
</style>
<?php  if($do == 'display') { ?>
<div class="panel panel-default">
	<div class="table-responsive panel-body">
		<table class="table">
			<thead>
				<tr>
					<th style="width:50px">序号</th>
					<th>分享标题</th>
					<th style="width:200px; text-align:right;">操作</th>
				</tr>
			</thead>
			<tbody>
               <?php  if($list) { ?>
				<?php  if(is_array($list)) { foreach($list as $item) { ?>
				<tr>
					<td><?php  echo $item['id'];?></td>
					<td>
						<a href="<?php  echo $this->createWebUrl('gongdengfenxiang', array('act' => 'post','id' => $item['id']))?>" style="color:#333;">
                            <?php  if($item['classname']) { ?><?php  echo "["; ?><?php  echo $item['classname'];?><?php  echo "] "; ?><?php  } ?><?php  echo $item['title'];?></a>
					</td>
					<td style="text-align:right; position:relative;">
               
						<a href="<?php  echo $this->createWebUrl('gongdengfenxiang', array('act' => 'post','id' => $item['id']))?>" title="编辑">编辑</a>&nbsp;-&nbsp;
						<a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" 
                        href="<?php  echo $this->createWebUrl('gongdengfenxiang', array('act' => 'delete','id' => $item['id']))?>" title="删除">删除</a>
					</td>
				</tr>
				<?php  } } ?>
            <?php  } else { ?>
				<tr>
					<td></td>
					<td>
						<a href="#" style="color:#333;">暂无分享</a>
					</td>
				</tr>            
            <?php  } ?>
			</tbody>
		</table>
	</div>
</div>
<?php  echo $pager;?>
<?php  } else if($do == 'post') { ?>
<div class="clearfix">
<?php  if($edit){$func = 'edit';}else{$func = 'add';} ?>
<form class="form-horizontal form" action="<?php  echo $this->createWebUrl('gongdeng', array('act' => $func,'id' => $id))?>" method="post" enctype="multipart/form-data">
	<div class="panel panel-default">
		<div class="panel-heading">添加分享</div>
		<div class="panel-body">
				<input type="hidden" name="id" value="<?php  echo $item['id'];?>">
                
          <!--    <div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">供灯分类</label>
					<div class="col-sm-8 col-xs-12">
						 <select name="classname">
                         <?php  if($getclass['class_id']){ ?>
                            <option value=<?php  echo $getclass['class_id'];?>><?php  echo $getclass['classname'];?></option>
                         <?php  }else{ 
                                    if($item['class_id']){ ?>
                                        <option value=<?php  echo $classfind['class_id'];?>><?php  echo $classfind['classname'];?></option>
                              <?php  }else{ ?>
                                        <option value="0">请选择供灯分类</option>
                                    <?php  } 
                                    foreach($class as $c){ 
                                        if($c['class_id']!=$classfind['class_id']){ ?>
                                            <option value=<?php  echo $c['class_id'];?>><?php  echo $c['classname'];?></option>
                                  <?php  }
                                    }
                                } ?>
				         </select>
					</div>
				</div>  -->
                
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享标题</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" placeholder="" name="title" value="<?php  echo $item['title'];?>">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享价格</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" placeholder="" name="prise" value="<?php  echo $item['title'];?>">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享图片</label>
					<div class="col-sm-8 col-xs-12">
						<?php  echo tpl_form_field_image('thumb', $item['image'])?>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
					<div class="col-sm-9 col-xs-12">
						<label>
						（大图片建议尺寸：360像素 * 200像素）
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享内容</label>
					<div class="col-sm-8 col-xs-12">
						<?php  echo tpl_ueditor('content', $item['content']);?>
					</div>
				</div>
		</div>
	</div>

	<div class="form-group">
		<div class="col-sm-12">
			<input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
		</div>
	</div>
</form>
</div>
<?php  } ?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>